import {defHttp} from '/@/utils/http/axios';

enum Api {
  list = '/course/csSemester/list',
  save='/course/csSemester/add',
  edit='/course/csSemester/edit',
  deleteOne = '/course/csSemester/delete',
  changeStatus = '/course/csSemester/switchStatus',
}
export const switchStatus = (params,handleSuccess) => {
  return defHttp.get({url: Api.changeStatus, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}
